# Maintainer: Joan Karadimov <joan.karadimov@gmail.com>

_realname=dcraw
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
conflicts=("${MINGW_PACKAGE_PREFIX}-gimp-ufraw")
pkgver=9.28
pkgrel=1
pkgdesc="Decoder for any raw image from any digital camera"
arch=('any')
url="https://www.dechifro.org/dcraw/"
license=("GPLv2")
options=('strip')
depends=("${MINGW_PACKAGE_PREFIX}-lcms2"
         "${MINGW_PACKAGE_PREFIX}-jasper"
         "${MINGW_PACKAGE_PREFIX}-libjpeg-turbo")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc")
source=("https://www.dechifro.org/${_realname}/${_realname}.c")
sha256sums=('d18d9e43a096eea04eee2148e53068f8fa45ce95395d97128b1aa37b477eab43')

prepare() {
  cd "${srcdir}"
}

build() {
  [[ -d build-${MINGW_CHOST} ]] && rm -rf build-${MINGW_CHOST}
  mkdir -p build-${MINGW_CHOST} && cd build-${MINGW_CHOST}

  gcc -o ${_realname} -O4 ../${_realname}.c -lm -ljasper -ljpeg -llcms2 -lws2_32
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  install -Dm0755 "${_realname}.exe" "${pkgdir}${MINGW_PREFIX}/bin/${_realname}.exe"
}
